package com.example.mes.web.controller;
import com.example.mes.model.Respository;
import com.example.mes.service.interfase.IRespositoryService;
import com.example.mes.webSocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.websocket.EncodeException;
import java.io.IOException;
import java.util.List;
@Controller
public class indexController {
    @RequestMapping("login-error")
    public String login_erroe(){
        return "error.html";
    }
    @RequestMapping("index")
    public String index(){
        return "index.html";
    }
    @RequestMapping("login")
    public String login(){
        return "login.html";
    }
    @RequestMapping("403")
    public String error(){
        return "403.html";
    }
    @Autowired
    WebSocketServer webSocketServer;
    @Autowired
    IRespositoryService respositoryService;
    @RequestMapping("test")
    public void  test() throws IOException, EncodeException {
        System.out.println(webSocketServer);
        List<Respository> list =  respositoryService.list();
        System.out.println(list);
        webSocketServer.sendMessage(list);
    }
}
